home *** CD-ROM | disk | FTP | other *** search
/ Multimedia Jumpstart / Multimedia Microsoft Jumpstart Version 1.1a (Microsoft).BIN / develpmt / sdk / vfw11.win / vfwdk / libinit.as_ / libinit.bin
Encoding:
Text File  |  1993-11-19  |  4.9 KB  |  196 lines

  1.     page    ,132
  2. ;-----------------------------Module-Header-----------------------------;
  3. ; Module Name:  LIBINIT.ASM
  4. ;
  5. ; library stub to do local init for a Dynamic linked library
  6. ;
  7. ; Exported Functions:   none
  8. ;
  9. ; Public Functions:     none
  10. ;
  11. ; Public Data:        none
  12. ;
  13. ; General Description:
  14. ;
  15. ; Restrictions:
  16. ;
  17. ;   This must be the first object file in the LINK line, this assures
  18. ;   that the reserved parameter block is at the *base* of DGROUP
  19. ;
  20. ;-----------------------------------------------------------------------;
  21. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  22. ;
  23. ;   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  24. ;   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  25. ;   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  26. ;   PURPOSE.
  27. ;
  28. ;   Copyright (c) 1992, 1993  Microsoft Corporation.  All Rights Reserved.
  29. ;
  30. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  31.  
  32. ?PLM=1      ; PASCAL Calling convention is DEFAULT
  33. ?WIN=1        ; Windows calling convention
  34.  
  35.         .286
  36.     .xlist
  37.     include cmacros.inc
  38. ;       include windows.inc
  39.         .list
  40.  
  41. ifndef SEGNAME
  42.     SEGNAME equ <_TEXT>
  43. endif
  44.  
  45. createSeg %SEGNAME, CodeSeg, word, public, CODE
  46.  
  47. ;-----------------------------------------------------------------------;
  48. ;
  49. ;   externs from KERNEL
  50. ;
  51.         externFP    <LocalInit>
  52.         externFP    <FatalAppExit>
  53.  
  54. ;-----------------------------------------------------------------------;
  55. ;
  56. ;   LibMain is the function in C code we will call on a DLL load.
  57. ;   it is assumed in the same segment as we are.
  58. ;
  59.         externNP    <LibMain>
  60. ;;;;;;;;externFP    <LibMain>  ;; Use this line if LibMain is far call
  61.  
  62. ;-----------------------------------------------------------------------;
  63. ;
  64. ; Stuff needed to avoid the C runtime coming in, and init the windows
  65. ; reserved parameter block at the base of DGROUP
  66. ;
  67. sBegin  Data
  68. assumes DS,Data
  69.             org 0               ; base of DATA segment!
  70.  
  71.             DD  0               ; So null pointers get 0
  72. maxRsrvPtrs = 5
  73.             DW  maxRsrvPtrs
  74. usedRsrvPtrs = 0
  75. labelDP     <PUBLIC,rsrvptrs>
  76.  
  77. DefRsrvPtr  MACRO   name
  78. globalW     name,0
  79. usedRsrvPtrs = usedRsrvPtrs + 1
  80. ENDM
  81.  
  82. DefRsrvPtr  pLocalHeap          ; Local heap pointer
  83. DefRsrvPtr  pAtomTable          ; Atom table pointer
  84. DefRsrvPtr  pStackTop           ; top of stack
  85. DefRsrvPtr  pStackMin           ; minimum value of SP
  86. DefRsrvPtr  pStackBot           ; bottom of stack
  87.  
  88. if maxRsrvPtrs-usedRsrvPtrs
  89.             DW maxRsrvPtrs-usedRsrvPtrs DUP (0)
  90. endif
  91.  
  92. public  __acrtused
  93.     __acrtused = 1
  94.  
  95. sEnd        Data
  96.  
  97. ;-----------------------------------------------------------------------;
  98.  
  99. sBegin  CodeSeg
  100.         assumes cs,CodeSeg
  101.  
  102. ;--------------------------Private-Routine-----------------------------;
  103. ;
  104. ; LibEntry - called when DLL is loaded
  105. ;
  106. ; Entry:
  107. ;       CX    = size of heap
  108. ;       DI    = module handle
  109. ;       DS    = automatic data segment
  110. ;       ES:SI = address of command line (not used by a DLL)
  111. ;
  112. ; Returns:
  113. ;       AX = TRUE if success
  114. ; Error Returns:
  115. ;       AX = FALSE if error (ie fail load process)
  116. ; Registers Preserved:
  117. ;    SI,DI,DS,BP
  118. ; Registers Destroyed:
  119. ;       AX,BX,CX,DX,ES,FLAGS
  120. ; Calls:
  121. ;    None
  122. ; History:
  123. ;
  124. ;       06-27-89 -by-  Todd Laney [ToddLa]
  125. ;    Created.
  126. ;-----------------------------------------------------------------------;
  127.         assumes ds,Data
  128.         assumes es,nothing
  129.  
  130. cProc   LibEntry,<FAR,PUBLIC,NODATA>,<>
  131. cBegin
  132. ifdef DEBUG
  133.         ;
  134.         ; if this module is not linked first the reserved parameter block
  135.         ; will not be initialized correctly, check for this and
  136.         ;
  137.         lea     ax,pLocalHeap
  138.         cmp     ax,6
  139.         je      RsrvPtrsOk
  140.  
  141. RsrvPtrsHosed:
  142.         int     3
  143.  
  144.         lea     ax,RsrvPtrsMsg
  145.         cCall   FatalAppExit,<0,cs,ax>
  146.         jmp     RsrvPtrsOk
  147.  
  148. RsrvPtrsMsg:
  149.         db      'RsrvPtrs hosed!',0
  150.  
  151. RsrvPtrsOk:
  152. endif
  153.     ;
  154.         ; Push frame for LibMain (hModule,cbHeap,lpszCmdLine)
  155.     ;
  156.     push    di
  157.     push    cx
  158.     push    es
  159.     push    si
  160.  
  161.         ;
  162.         ; Init the local heap (if one is declared in the .def file)
  163.         ;
  164.         jcxz no_heap
  165.  
  166.         cCall   LocalInit,<0,0,cx>
  167.  
  168. no_heap:
  169.         cCall   LibMain
  170. cEnd
  171.  
  172. ;--------------------------Exported-Routine-----------------------------;
  173. ;
  174. ;   WEP()
  175. ;
  176. ;   called when the DLL is unloaded, it is passed 1 WORD parameter that
  177. ;   is TRUE if the system is going down, or zero if the app is
  178. ;
  179. ;   WARNING:
  180. ;
  181. ;       This function is basicly useless, you cant can any kernel function
  182. ;       that may cause the LoadModule() code to be reentered..
  183. ;
  184. ;-----------------------------------------------------------------------;
  185.         assumes ds,nothing
  186.         assumes es,nothing
  187.  
  188. cProc   WEP,<FAR,PUBLIC,NODATA>,<>
  189.         ParmW  WhyIsThisParamBogusDave?
  190. cBegin
  191. cEnd
  192.  
  193. sEnd    CodeSeg
  194.  
  195.         end     LibEntry
  196.